package view.macrogui
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import model.macro.Player;
	
	/**
	 */
	public class PlayerInfo extends Sprite implements SidebarItem
	{
		private const TITLE_FORMAT:TextFormat = new TextFormat("Helvetica", 20, 0xFFFFFF);
		private const GOLD_FORMAT:TextFormat = new TextFormat("Helvetica", 12, 0xFFFF44);
		private const BASIC_FORMAT:TextFormat = new TextFormat("Helvetica", 12, 0xFFFFFF);
		
		private var name_field:TextField;
		private var gold_field:TextField;
		private var research_button:TextField;
		
		public function PlayerInfo()
		{
			name_field = new TextField();
			name_field.selectable = false;
			name_field.defaultTextFormat = TITLE_FORMAT;
			addChild(name_field);
			
			gold_field = new TextField();
			gold_field.selectable = false;
			gold_field.defaultTextFormat = GOLD_FORMAT;
			addChild(gold_field);
			
			research_button = new TextField();
			research_button.selectable = false;
			research_button.defaultTextFormat = BASIC_FORMAT;
			research_button.text = "research button";
			addChild(research_button);
			
			gold_field.y = name_field.y + 24;
			research_button.y = gold_field.y + 16;
		}
		
		public function update(player:Player):void
		{
			if (player == null)
			{
				visible = false;
				return;
			}
			else
			{
				visible = true;
				name_field.text = player.name;
				gold_field.text = "gold: " + player.gold;
			}
		}
		
		public function getHeight():int
		{
			if (visible)
				return 80;
			else
				return 0;
		}
	}

}